//Copyright 2012 Trevin Liberty
//GNU GPL v3
//Author: Trevin Liberty
//
//Draws and Updates arrows that are shot by an archer.
//SEE: Sprite.h MovingSprite.h Archer.h

#ifndef ARROW_H
#define ARROW_H

#include "Sprite.h"

//See comment at top of file for a complete description
class Arrow : public Sprite {
private:
	Map* map;

	static bitmapImage* images;
	int numImages;
	Point<int> imageLoc;

	Doohickey* target;

	Point<float> vect;
	Point<float> startPos;

	float range;

	char team;

	void loadBitmap();
	bool inRange();

public:
	//Constructor
	//SEE: Structs.h->struct Map{...}
	Arrow(Map* map);

	//Given a starting position and vector. This selects the correct 
	//	direction for the arrow to be facing and sets it to draw and update.
	//	PARAMS:
	//Point<float> p: The starting position of the arrow. In screen cords.
	//Point<float> v: The directional vector of the arrow.
	//	Example: playerPos - targetPos = directionalVector. Then normalize.
	//Doohickey* target: A pointer to the arrows target. If the arrow is within a close distance to this target,
	//	the target will take damage.
	void startArrow(Point<float> p, Point<float> v, Doohickey* target);

	//Returns true if the arrow is NOT currently being used. (Not being updated/drawn)
	bool isOK() const {return ok;}

	//Stops the arrow from being updated or drawn.
	bool stop() {ok = false;}

	//Sets the team of the arrow, so the arrow doesn't damage its own team mates.
	//ATTN: Does nothing at the moment.
	//TODO: Make it do something. Remove target and let it damage any Entity of the other team?
	void setTeam(char c) {team = c;}

	//Removes the arrows target.
	//Makes the arrow do no damage. AKA Will NOT hit/stop at ANY Entity.
	void removeTarget() {target = NULL;}

	//Updates the arrow
	void update();

	//Draws the arrow
	void draw(Point<float> cameraPos);

	//Deletes static bitmap Images.
	void deleteImages();
};

#endif